package com.huitu.whht.base.core.api.rel.cmd;

import com.huitu.api.rest.AbstractApiResource;
import com.huitu.commons.PageUtils;
import com.huitu.whht.api.core.common.response.ApiResultBuilder;
import com.huitu.whht.api.core.common.annotations.SzyCoreApiResource;
import com.huitu.whht.api.core.common.annotations.SzyCoreApiService;
import com.huitu.whht.api.core.common.response.StatusRespBuilder;

import com.huitu.whht.base.core.api.rel.cmd.entities.RelCmdKind;

import com.huitu.whht.base.core.api.rel.cmd.entities.RelCmdKindQo;
import com.huitu.whht.base.core.api.rel.cmd.service.IRelCmdKindService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;

import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

/**
 * 说明: API,表名称: REL_CMD_KIND <br/>
 * 日期: 2019-04-11
 * @author LiuCW
 */
@Component
@SzyCoreApiResource
@Path("rel/cmd/kind")
public class RelCmdKindResource extends AbstractApiResource {

    private static final Logger LOGGER = LoggerFactory.getLogger(RelCmdKindResource.class);

    private static final String UUID = "dcaf1ee2-3147-4e99-be56-a50d26296593";

    @Override
    public String getUUID() {
        return UUID;
    }

    @Autowired
    @SzyCoreApiService
    IRelCmdKindService relCmdKindService;

    /**
     * @api {get} rel/cmd/kind/{id} [R][G]根据主键查询
     * @apiDescription [G]根据主键查询REL_CMD_KIND()数据
     * @apiName (generate)select by primary key
     * @apiGroup REL_CMD_KIND-
     * @apiVersion 1.0.0
     * @apiSampleRequest rel/cmd/kind/1
     * @apiParam   {Integer}        id                 【必须】暂无注释
     * @apiSuccess {Integer}        id                 暂无注释
     * @apiSuccess {Integer}        afn                暂无注释
     * @apiSuccess {Integer}        protype            暂无注释
     * @apiSuccess {String}         cmdname            暂无注释
     * @apiSuccessExample 请求成功:
     * HTTP/1.1 200 OK
     * {
     * "result": {
     * "id": 1,
     * "afn": 2,
     * "protype": 1,
     * "cmdname": "链路检测"
     *  }
     * }
     * @apiUse exceptions
     */
    @GET
    @Path("{id}")
    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
    public Response selectByPrimaryKey(@PathParam("id") Integer id) {
        LOGGER.info("根据主键查询 ,参数 id:{}", id);
        return Response.ok(ApiResultBuilder.create(this, relCmdKindService.selectByPrimaryKey(id))).build();
    }

    /**
     * @api {post} rel/cmd/kind/list [R][G]根据条件查询
     * @apiDescription [G]根据条件查询REL_CMD_KIND()数据
     * @apiName (generate)select by filter
     * @apiGroup REL_CMD_KIND-
     * @apiVersion 1.0.0
     * @apiSampleRequest rel/cmd/kind/list
     * @apiParam   {Integer}        idMin              (最小)暂无注释
     * @apiParam   {Integer}        idMax              (最大)暂无注释
     * @apiParam   {Integer}        afnMin             (最小)暂无注释
     * @apiParam   {Integer}        afnMax             (最大)暂无注释
     * @apiParam   {Integer}        protypeMin         (最小)暂无注释
     * @apiParam   {Integer}        protypeMax         (最大)暂无注释
     * @apiParam   {String}         cmdname            暂无注释
     * @apiSuccess {Integer}        id                 暂无注释
     * @apiSuccess {Integer}        afn                暂无注释
     * @apiSuccess {Integer}        protype            暂无注释
     * @apiSuccess {String}         cmdname            暂无注释
     * @apiSuccessExample 请求成功:
     * HTTP/1.1 200 OK
     * {
     * "result": [{
     * "id": 1,
     * "afn": 2,
     * "protype": 1,
     * "cmdname": "链路检测"
     *  }]
     * }
     *
     * @apiSuccessExample 分页请求:
     * request header: Rang={max=50;size=50;field=TS DESC}
     * HTTP/1.1 200 OK
     * {
     * "result": [{
     * "id": 1,
     * "afn": 2,
     * "protype": 1,
     * "cmdname": "链路检测"
     *  }],
     * "paging": {
     * "count": 3,
     * "total": 120,
     * "finale": false,
     * "index": 1
     * }
     * }
     * @apiUse header_rang
     * @apiUse exceptions
     */
    @POST
    @Path("list")
    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
    public Response selectList(RelCmdKindQo filter) {
        PageUtils.startPageFromRang();
        LOGGER.info("根据条件查询 ,参数 RelCmdKindQo:{}", filter);
        return Response.ok(ApiResultBuilder.create(this, relCmdKindService.selectList(filter))).build();
    }

    /**
     * @api {put} rel/cmd/kind [C][G]新增数据
     * @apiPrivate
     * @apiDescription [G]新增REL_CMD_KIND()数据
     * @apiName (generate)add data
     * @apiGroup REL_CMD_KIND-
     * @apiVersion 1.0.0
     * @apiParam   {Integer}        id                 【必须】暂无注释
     * @apiParam   {Integer}        afn                暂无注释
     * @apiParam   {Integer}        protype            暂无注释
     * @apiParam   {String}         cmdname            暂无注释
     * @apiSuccess {Integer}        status             1:新增成功;0:新增失败.
     * @apiSuccess {String}         message            成功/失败消息内容
     * @apiSuccess {Object}         data               额外返回的数据,通常包含新增数据的主键值
     * @apiSampleRequest rel/cmd/kind
     * @apiSuccessExample 新增成功:
     * HTTP/1.1 200 OK
     * {
     * "result": {
     * "status":1,
     * "message":"成功",
     * "data":{
     *   "id": 1
     *      }
     *   }
     * }
     @apiSuccessExample 新增失败:
     * HTTP/1.1 200 OK
     * {
     * "result": {
     * "status":0,
     * "message":"失败",
     * "data":{
     *   "id": 1
     *      }
     *   }
     * }
     * @apiParamExample {json} 请求示例:
     * {
     * "id": 1,
     * "afn": 2,
     * "protype": 1,
     * "cmdname": "链路检测"
     * }
     * @apiUse exceptions
     */
    @PUT
    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
    public Response insert(RelCmdKind record) {
        LOGGER.info("新增 ,参数 RelCmdKind:{}", record);
        return Response.ok(ApiResultBuilder.create(this, StatusRespBuilder.insert(relCmdKindService.insertSelective(record),record))).build();
    }

    /**
     * @api {post} rel/cmd/kind/insertBatch [C][G]批量新增数据
     * @apiPrivate
     * @apiDescription [G]批量新增REL_CMD_KIND()数据
     * @apiName (generate)addBatch data
     * @apiGroup REL_CMD_KIND-
     * @apiVersion 1.0.0
     * @apiParam   {Integer}        id                 【必须】暂无注释
     * @apiParam   {Integer}        afn                暂无注释
     * @apiParam   {Integer}        protype            暂无注释
     * @apiParam   {String}         cmdname            暂无注释
     * @apiSuccess {Integer}        status             1:新增成功;0:新增失败.
     * @apiSuccess {String}         message            成功/失败消息内容
     * @apiSuccess {Object}         data               额外返回的数据,通常包含新增数据的主键值
     * @apiSampleRequest rel/cmd/kind/insertBatch
     * @apiSuccessExample 新增成功:
     * HTTP/1.1 200 OK
     * {
     * "result": {
     * "status":1,
     * "message":"成功",
     * "data":{
     *   "id": 1
     *      }
     *   }
     * }
     @apiSuccessExample 新增失败:
     * HTTP/1.1 200 OK
     * {
     * "result": {
     * "status":0,
     * "message":"失败",
     * "data":{
     *   "id": 1
     *      }
     *   }
     * }
     * @apiParamExample {json} 请求示例:
     * [{
     * "id": 1,
     * "afn": 2,
     * "protype": 1,
     * "cmdname": "链路检测"
     * }]
     * @apiUse exceptions
     */
    @POST
    @Path("insertBatch")
    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
    public Response insertBatch(List<RelCmdKind> recordList) {
        LOGGER.info("批量新增 ,参数 RelCmdKind:[]", recordList);
        return Response.ok(ApiResultBuilder.create(this, StatusRespBuilder.insert(relCmdKindService.insertBatch(recordList),recordList))).build();
    }

    /**
     * @api {put} rel/cmd/kind/{id}/update [U][G]根据主键修改
     * @apiPrivate
     * @apiDescription [G]根据主键修改REL_CMD_KIND()数据
     * @apiName (generate)update data
     * @apiGroup REL_CMD_KIND-
     * @apiVersion 1.0.0
     * @apiParam   {Integer}        id                 【必须】暂无注释
     * @apiParam   {Integer}        afn                暂无注释
     * @apiParam   {Integer}        protype            暂无注释
     * @apiParam   {String}         cmdname            暂无注释
     * @apiSuccess {Integer}        status             1:修改成功;0:要修改的数据不存在(可能已被删除)
     * @apiSuccess {String}         message            成功/失败消息内容
     * @apiSuccess {Object}         data               额外返回的数据
     * @apiSampleRequest rel/cmd/kind/1/update
     * @apiSuccessExample 修改成功:
     * HTTP/1.1 200 OK
     * {
     * "result": {
     * "status":1,
     * "message":"成功",
     * "data":null
     *   }
     * }
     * @apiSuccessExample 修改失败:
     * HTTP/1.1 200 OK
     * {
     * "result": {
     * "status":0,
     * "message":"失败",
     * "data":null
     *   }
     * }
     * @apiParamExample {json} 请求示例:
     * {
     * "id": 1,
     * "afn": 2,
     * "protype": 1,
     * "cmdname": "链路检测"
     * }
     * @apiUse exceptions
     */
    @PUT
    @Path("{id}/update")
    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
    public Response update(@PathParam("id") Integer id, RelCmdKind record) {
        record.setId(id);
        LOGGER.info("根据主键修改 ,参数 RelCmdKind:{}", record);
        return Response.ok(ApiResultBuilder.create(this, StatusRespBuilder.update(relCmdKindService.updateByPrimaryKey(record)))).build();
    }

    /**
     * @api {put} rel/cmd/kind/{id}/update-selective [U][G]根据主键修改(只修改非null字段)
     * @apiPrivate
     * @apiDescription [G]根据主键修改REL_CMD_KIND()数据,只修改非null字段
     * @apiName (generate)update selected data
     * @apiGroup REL_CMD_KIND-
     * @apiVersion 1.0.0
     * @apiParam   {Integer}        id                 暂无注释
     * @apiParam   {Integer}        afn                暂无注释
     * @apiParam   {Integer}        protype            暂无注释
     * @apiParam   {String}         cmdname            暂无注释
     * @apiSuccess {Integer}        status             1:修改成功;0:要修改的数据不存在(可能已被删除)
     * @apiSuccess {String}         message            成功/失败消息内容
     * @apiSuccess {Object}         data               额外返回的数据
     * @apiSampleRequest rel/cmd/kind/1/update-selective
     * * @apiSuccessExample 修改成功:
     * HTTP/1.1 200 OK
     * {
     * "result": {
     * "status":1,
     * "message":"成功",
     * "data":null
     *   }
     * }
     * @apiSuccessExample 修改失败:
     * HTTP/1.1 200 OK
     * {
     * "result": {
     * "status":0,
     * "message":"失败",
     * "data":null
     *   }
     * }
     * @apiParamExample {json} 请求示例:
     * {
     * "id": 1,
     * "afn": 2,
     * "protype": 1,
     * "cmdname": "链路检测"
     * }
     * @apiUse exceptions
     */
    @PUT
    @Path("{id}/update-selective")
    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
    public Response updateSelective(@PathParam("id") Integer id, RelCmdKind record) {
        record.setId(id);
        LOGGER.info("根据主键修改(只修改非null字段) ,参数 RelCmdKind:{}", record);
        return Response.ok(ApiResultBuilder.create(this, StatusRespBuilder.update(relCmdKindService.updateByPrimaryKeySelective(record)))).build();
    }

    /**
     * @api {post} rel/cmd/kind/updateBatch [U][G]根据主键批量修改(只修改非null字段)
     * @apiPrivate
     * @apiDescription [G]根据批量主键修改REL_CMD_KIND()数据,只修改非null字段
     * @apiName (generate)updateBatch selected data
     * @apiGroup REL_CMD_KIND-
     * @apiVersion 1.0.0
     * @apiParam   {Integer}        id                 暂无注释
     * @apiParam   {Integer}        afn                暂无注释
     * @apiParam   {Integer}        protype            暂无注释
     * @apiParam   {String}         cmdname            暂无注释
     * @apiSuccess {Integer}        status             1:修改成功;0:要修改的数据不存在(可能已被删除)
     * @apiSuccess {String}         message            成功/失败消息内容
     * @apiSuccess {Object}         data               额外返回的数据
     * @apiSampleRequest  rel/cmd/kind/updateBatch
     * * @apiSuccessExample 修改成功:
     * HTTP/1.1 200 OK
     * {
     * "result": {
     * "status":1,
     * "message":"成功",
     * "data":null
     *   }
     * }
     * @apiSuccessExample 修改失败:
     * HTTP/1.1 200 OK
     * {
     * "result": {
     * "status":0,
     * "message":"失败",
     * "data":null
     *   }
     * }
     * @apiParamExample {json} 请求示例:
     * [{
     * "id": 1,
     * "afn": 2,
     * "protype": 1,
     * "cmdname": "链路检测"
     * }]
     * @apiUse exceptions
     */
    @POST
    @Path("updateBatch")
    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
    public Response updateBatch(List<RelCmdKind> record) {
        LOGGER.info("根据主键批量修改(只修改非null字段) ,参数 RelCmdKind:{}", record);
        return Response.ok(ApiResultBuilder.create(this, StatusRespBuilder.update(relCmdKindService.updateBatch(record)))).build();
    }

    /**
     * @api {delete} rel/cmd/kind/{id} [D][G]根据主键删除
     * @apiPrivate
     * @apiDescription [G]根据主键删除REL_CMD_KIND()数据
     * @apiName (generate)delete by primary key
     * @apiGroup REL_CMD_KIND-
     * @apiVersion 1.0.0
     * @apiSampleRequest rel/cmd/kind/1
     * @apiParam   {Integer}        id                 【必须】暂无注释
     * @apiSuccess {Integer}        status             1:删除成功;0:要删除的数据不存在(可能已被删除).
     * @apiSuccess {String}         message            成功/失败消息内容
     * @apiSuccess {Object}         data               额外返回的数据
     * @apiSuccessExample 删除成功:
     * HTTP/1.1 200 OK
     * {
     * "result": {
     * "status":1,
     * "message":"成功",
     * "data":null
     *   }
     * }
     * @apiSuccessExample 删除失败:
     * HTTP/1.1 200 OK
     * {
     * "result": {
     * "status":0,
     * "message":"失败",
     * "data":null
     *   }
     * }
     * @apiUse exceptions
     */
    @DELETE
    @Path("{id}")
    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
    public Response delete(@PathParam("id") Integer id) {
        LOGGER.info("根据主键删除 ,参数 id:{}", id);
        Integer rows = relCmdKindService.deleteByPrimaryKey(id);
        return Response.ok(ApiResultBuilder.create(this, StatusRespBuilder.delete(rows))).build();
    }

    /**
     * @api {delete} rel/cmd/kind/by-filter [D][G]根据条件删除
     * @apiPrivate
     * @apiDescription [G]根据条件删除REL_CMD_KIND()数据
     * @apiName (generate)delete by filter
     * @apiGroup REL_CMD_KIND-
     * @apiVersion 1.0.0
     * @apiSampleRequest rel/cmd/kind/by-filter
     * @apiParam   {Integer}        idMin              (最小)暂无注释
     * @apiParam   {Integer}        idMax              (最大)暂无注释
     * @apiParam   {Integer}        afnMin             (最小)暂无注释
     * @apiParam   {Integer}        afnMax             (最大)暂无注释
     * @apiParam   {Integer}        protypeMin         (最小)暂无注释
     * @apiParam   {Integer}        protypeMax         (最大)暂无注释
     * @apiParam   {String}         cmdname            暂无注释
     * @apiSuccess {Integer}        status             通常1或者>1:删除成功;0:没有符合条件的数据.
     * @apiSuccess {String}         message            成功/失败消息内容
     * @apiSuccess {Object}         data               额外返回的数据
     * @apiSuccessExample 删除成功:
     * HTTP/1.1 200 OK
     * {
     * "result": {
     * "status":1,
     * "message":"成功",
     * "data":null
     *   }
     * }
     * @apiSuccessExample 删除失败:
     * HTTP/1.1 200 OK
     * {
     * "result": {
     * "status":0,
     * "message":"失败",
     * "data":null
     *   }
     * }
     * @apiUse exceptions
     */
    @DELETE
    @Path("by-filter")
    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
    public Response deleteByFilter(RelCmdKindQo filter) {
        LOGGER.info("根据条件删除 ,参数 RelCmdKindQo:{}", filter);
        Integer rows = relCmdKindService.deleteByFilter(filter);
        return Response.ok(ApiResultBuilder.create(this, StatusRespBuilder.delete(rows))).build();
    }
}
